-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libcnb-test: Clean up Docker volumes after each test #741
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
edmorley
added
bug
Something isn't working
enhancement
New feature or request
libcnb-test
labels
Nov 16, 2023
edmorley
commented
Nov 16, 2023
Malax
requested changes
Nov 16, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left one comment, let's discuss there - otherwise this has my approval. :)
When using `pack build`, by default Pack will create two Docker volumes for caching - one for the build layer cache, and the other for the launch layer cache. Pack bases the names for these volumes on the app image name, so that the next time a build is performed with the same app image name, the associated cache is used for that rebuild. When libcnb-test runs tests, it intentionally uses a random Docker image name for each new test, and then tears down the image and any associated containers after the tests. However, until now the Docker volumes automatically created by Pack were not being removed, which can cause issues when running the tests locally, since the Docker VM can run out of disk space - as seen in #570. The leftover volumes can also be seen in the tests log output added in #740. Pack doesn't currently offer a "clean up the volumes associated with this app name" feature, so we have to remove these volumes manually. To do so we need the volume name - which we achieve by generating a name ourselves, and passing it to `pack build` using the `--cache` options, so Pack uses our volume name instead of generating its own automatic volume name. Since we're now cleaning up not only images but volumes too, I've refactored the way resources are cleaned up, to reduce the amount of duplication (since otherwise we'd need to handle the "still clean up for expected failures" case for volumes too). This new implementation also solves #735 and #736. Fixes #570. Fixes #735. Fixes #736. GUS-W-13195631. GUS-W-14503186. GUS-W-14503192.
edmorley
force-pushed
the
edmorley/cache-volume-cleanup
branch
from
November 16, 2023 17:46
9794db0
to
851242e
Compare
colincasey
approved these changes
Nov 16, 2023
edmorley
force-pushed
the
edmorley/cache-volume-cleanup
branch
from
November 16, 2023 22:15
851242e
to
d11167b
Compare
Malax
approved these changes
Nov 17, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When using
pack build
, by default Pack will create two Docker volumes for caching - one for the build layer cache, and the other for the launch layer cache. Pack bases the names for these volumes on the app image name, so that the next time a build is performed with the same app image name, the associated cache is used for that rebuild.When libcnb-test runs tests, it intentionally uses a random Docker image name for each new test, and then tears down the image and any associated containers after the tests.
However, until now the Docker volumes automatically created by Pack were not being removed, which can cause issues when running the tests locally, since the Docker VM can run out of disk space - as seen in #570. The leftover volumes can also be seen in the tests log output added in #740.
Pack doesn't currently offer a "clean up the volumes associated with this app name" feature, so we have to remove these volumes manually. To do so we need the volume name - which we achieve by generating a name ourselves, and passing it to
pack build
using the--cache
options, so Pack uses our volume name instead of generating its own automatic volume name.Since we're now cleaning up not only images but volumes too, I've refactored the way resources are cleaned up, to reduce the amount of duplication (since otherwise we'd need to handle the "still clean up for expected failures" case for volumes too). This new implementation also solves #735 and #736.
Fixes #570.
Fixes #735.
Fixes #736.
GUS-W-13195631.
GUS-W-14503186.
GUS-W-14503192.